//
//  RCAdModel.m
//  ReCite
//
//  Created by Miles on 10-05-14.
//  Copyright 2010 Miles Thorogood
//  greenmeat.net. All rights reserved.
//

#import "RCAdModel.h"


@interface RCAdModel() 

-(void) populateAdAtributes ;

@end 

@implementation RCAdModel

//@synthesize textUrl, audioUrl, imageUrl, ad_identifier, type ;
@synthesize dataDictionary ;
@synthesize thisAd ;

-(id) initWithDictionary:(NSMutableDictionary *) dictionary {
	self = [super init] ;
	if (self) {
		self.dataDictionary = dictionary ;
		[self populateAdAtributes] ;
	}
	return self ;
}

-(void) populateAdAtributes {
	if(![[dataDictionary objectForKey:@"audio"] isEqualToString:@""]) {
		thisAd.audioUrl = [NSURL URLWithString:[dataDictionary objectForKey:@"audio"]];
	}
	if(![[dataDictionary objectForKey:@"image"] isEqualToString:@""]) {
		thisAd.imageUrl = [NSURL URLWithString:[dataDictionary objectForKey:@"image"]];
	}
	if(![[dataDictionary objectForKey:@"text"] isEqualToString:@""]) {
		thisAd.textUrl = [NSURL URLWithString:[dataDictionary objectForKey:@"text"]];
	}
	if(![[dataDictionary objectForKey:@"ad"] isEqualToString:@""]) {
		thisAd.ad_identifier = [dataDictionary objectForKey:@"ad"] ;
	}
	thisAd.location = [dataDictionary objectForKey:@"location"] ;
	
}

@end
